<?php 
require_once 'include.php';
if($_REQUEST['orderStatus']==null)$orderStatus=4;//4代表列出所有订单
else $orderStatus=intval($_REQUEST['orderStatus']);
$allOrders=getAllOrders($orderStatus);
$orderTotalNum=getOrderTotal();
?>
<html>
	<head>
		<meta charset="utf-8">
		<title>订单管理</title>
		<meta name="keywords" content="">
		<meta name="description" content="">
		<link rel="stylesheet" href="userindex/css/safe/ms-style.min.css" />
		<link rel="stylesheet" href="userindex/css/safe/personal_member.min.css" />
		<script src="js/jquery-1.6.js" type="text/javascript"></script>
	</head>
<body >
	<?php include 'header.php';?>
		<div id="ms-center" class="personal-member">
			<div class="cont">
				<div class="cont-side">
				<div class="side-neck" style="margin-top: 20px;">
						<i></i>
					</div>
					<div class="ms-side" style="margin-top: 20px;" >
						<article class="side-menu side-menu-off">
							<dl class="side-menu-tree" style="padding-left: 50px;">
								<dt><a href="userHome.php"><img src="userindex/img/user_icon2.png"  style="margin-right: 10px;margin-left: -20px;"/>
									个人中心</a></dt>
								<dd><a href="userModify.php">修改资料</a></dd>
								<dd><a href="Address.php">收货地址</a></dd>
								<dt><img src="userindex/img/shoppingcart.png"  style="margin-right: 10px;margin-left: -20px;"/>我的购物车</dt>
								<dt><img src="userindex/img/file.png"  style="margin-right: 10px;margin-left: -20px;"/>订单管理</dt>
								<dd><a>我的订单</a></dd>						
							</dl>

							<a ison="on" class="switch-side-menu icon-up-side"><i></i></a>
						</article>
					</div>
				</div>
				<div class="cont-main">
					<div class="main-wrap mt15" style="border: 0px;">
						    <div style="width: 680px;padding: 10px;float: left;background-color: #fff;height: 50px;">
								<!-- <div style="border-top:1px #ccc solid;width: 650px;position: absolute;margin-top: 200px;margin-left: 20px;float: left;"></div> -->
								<div style="position: absolute;margin-top: 20px;font-size: 14px;color: #686868;float: left;">
									<a href="myorders.php"><span style="margin-left: 20px;">全部订单</span></a>
									<font style="color: #CF2D27;"><?php echo $orderTotalNum[3];?></font>
									<span style="margin-left: 40px;margin-right: 40px;">|</span>
									<a href="myorders.php?orderStatus=1"><span >待发货</span></a>
									<font style="color: #CF2D27;"><?php echo $orderTotalNum[1];?></font>
									<span style="margin-left: 40px;margin-right: 40px;">|</span>
									<a href="myorders.php?orderStatus=2"><span>待收货</span></a>
									<font style="color: #CF2D27;"><?php echo $orderTotalNum[2];?></font>
									<span style="margin-left: 40px;margin-right: 40px;">|</span>
									<a href="myorders.php?orderStatus=0"><span>待付款</span></a>
									<font style="color: #CF2D27;"><?php echo $orderTotalNum[0];?></font>								
								</div>
							</div>	
							<div class="profile-info">
								<div class="control-group clearfix " style="width: 1020px;margin-bottom: 0px;">
									<div>
                                        <div style="float:right;display: inline;margin-left:60px;display: inline-block;height: 25px;margin-right: -5px;padding-top: 10px;"> 
									    <img src="img/trash-拷贝.png"  style="height: 10px;width: 10px;" />
									           <font style="">订单回收站</font>
                                        </div> 
									 </div>
									
								</div>
							</div>
							
							<div id="index" class="tab-pane " >
								<div style="margin-left: 50px;height: 25px;" >
        							<input  type="text"  placeholder="输入商品标题或者订单号进行搜索 " style="width: 200px;height: 25px;font-size: 12px;" />
        							<button style="height: 100%;margin-left: -5px;border: 1px #ccc solid;font-size: 12px;color:#353535;background-color: #f2f2f2;width: 100px;">订单搜索</button>
								</div>
							</div>
							
<?php foreach ($allOrders as $allod):?>
<div class="shoppingCart comWidth">
	<div class="hr_25"></div>
	<div class="shopping_item">
		<h3 class="shopping_tit">订单号：<?php $listOrders=getOrderByNumber($allod['code'],$orderStatus);echo $allod['code']?>
			<a class="backCar">订单日期：<?php echo date('Y-m-d H:i:s',$allod['createtime'])?></a>
		</h3>
		<div class="shopping_cont pb_10">
			<div class="cart_inner">
				<div class="cart_head clearfix">
					<div class="cart_item t_name">商品名称</div>
					<div class="cart_item t_price_cart">单价(元)</div>
					<div class="cart_item t_return_cart">数量</div>
					<div class="cart_item t_num_cart">商品操作</div>
					<div class="cart_item t_subtotal_cart">实付款(元)</div>
					<div class="cart_item t_operator_cart">交易操作</div>
				</div>
				<?php foreach ($listOrders as $listod):?>
				<div class="cart_cont clearfix">
					<div class="cart_item t_name">
						<div class="cart_shopInfo clearfix">
							<img src="image_350/<?php echo getProImgsById($listod['pid'])[0]['albumPath'];?>" alt="">
							<div class="cart_shopInfo_cont">
								<p class="cart_link"><a href="#"><?php $proInfo=getProById($listod['pid']);echo $proInfo['pName']?></a></p>
								<p class="cart_info">其他信息</p>
							</div>
						</div>
					</div>
					<div class="cart_item t_price_cart" style="margin-top: 20px;"><span><?php echo $listod['price'] ?></span></div>
					<div class="cart_item t_price_cart" style="margin-top: 20px;"><span><?php echo $listod['num']?></span></div>
					<div class="cart_item t_subtotal_cart"><span><dl style="float: right;margin-right: 50px;margin-top: 20px;">退款/退货<br />投诉卖家<br>退运保险</dl></span></div>
					<div class="cart_item t_price_cart" style="margin-top: 20px;"><span><?php echo $listod['price'] ?></span></div>
						<?php if($listod['Status']==='0'):?>
						<a href="javascript:goPay('<?php echo $listod['code']?>',<?php echo getOrderTotalPrice($listod['code'])?>)">
							<button style="color: fff;background-color: #65b5ff;border: 0px;padding: 4px;margin-top: 40px;" >
							去付款</button></a>
						<?php elseif($listod['Status']==='1'):?>
						<button style="color: fff;background-color: #65b5ff;border: 0px;padding: 4px;margin-top: 20px;">等待发货</button>
						<?php elseif($listod['Status']==='2'):?>
						<a href="javascript:confirmReceipt(<?php echo $listod['pid'];?>,'<?php echo $listod['code']?>')">
						<button style="color: fff;background-color: #65b5ff;border: 0px;padding: 4px;margin-top: 20px;">确认收货</button>
						</a>
						<?php elseif($listod['Status']==='3'):?>
						<button style="color: fff;background-color: #65b5ff;border: 0px;padding: 4px;margin-top: 20px;">订单完成</button>
						<?php endif;?>
				</div>
				<?php endforeach;?>
			</div>
		</div>
	</div>
</div>
<?php endforeach;?>		
					<script type="text/javascript">
						function goPay(code,price){
							document.getElementById('item_name').value=code;
							document.getElementById('item_number').value=code;
							document.getElementById('amount').value=price;
							document.forms[0].submit();
						}
						function confirmReceipt(pid,code){
							var url="doAction.php?act=confirmReceipt";
							var data={"pid":pid,"code":code};
							var success=function(response){
									if(response.errno==0){
										alert("交易成功，已确认收货");
									}else{
										alert("确认收货失败");
									}
								}
							if(window.confirm("您确定要确认收货嘛？小心钱货两空喔！")){
    							
    							$.post(url,data,success,"json");
							}
						}
						</script>
		<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
			<input type="hidden" name="cmd" value="_xclick"> 
			<input type="hidden" name="business" value="1027577022-facilitator@qq.com">  
			<input type="hidden" id="item_name" name="item_name" value="">
			<input type="hidden" id="item_number" name="item_number" value="">
			<input type="hidden" name="currency_code" value="USD"> 
			<input type="hidden" id="amount" name="amount" value=""> 
			<input type="hidden" name="return" value="http://bxu2442430302.my3w.com/payment/paypal/pdt.php" />
			<input type="hidden" name="notify_url" value="http://bxu2442430302.my3w.com/payment/paypal/ipn.php" />
			<input type="hidden" name="cancel_return" value="http://bxu2442430302.my3w.com/payment/paypal/pdt.php" />
			<input value='US' type='hidden' name='lc'> 
		</form>

		<p style="text-align:right;margin-top: 10px;width: 100%;">
			<span class="fenye"><</span><span class="fenye" style="margin-left: 10px;">1</span><span class="fenye">2</span><span class="fenye">3</span>.....<span class="fenye">></span>共1页，到<input type="text" value="1" style="width: 20px;margin-left: 10px;margin-right: 10px;" />页<button  style="background-color: #f95555;padding: 3px;border: 0px;color: #fff;margin-left: 10px;width: 50px;border-radius:4px;">确认</button>
		</p>
							 </div>
						 </div>		   	
					</div>
				</div>
		<div class="clear"></div>
		<?php include 'footer.php';?>
	</body>

</html>